#include<bits/stdc++.h>
using namespace std;

int T;
int n, ans;
int a[200005];
bool op[200005];

void dfs(int dep)
{
    if (dep > n)
    {
        int t = 0;
        for (int i = 1; i <= n; i ++)
        {
            for (int j = i - 1; j >= 1; j --)
            {
                if (op[i] == op[j] && a[j] == a[i])
                {
                    t += a[i];
                    break;
                }
            }
        }
        ans = max(ans, t);
        return ;
    }
    op[dep] = 0;
    dfs(dep + 1);
    op[dep] = 1;
    dfs(dep + 1);
}

int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    cin >> T;
    while (T --)
    {
        ans = 0;
        cin >> n;
        for (int i = 1; i <= n; i ++)
        {
            cin >> a[i];
        }
        dfs(1);
        cout << ans << "\n";
    }
    return 0;
}
